package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.mvp.model.*
import com.baizan.daka.ui.contract.HomeFrgContract
import com.baizan.daka.mvp.model.bean.*
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.VipHomeContract

class VipHomePresenter(val mView: VipHomeContract.View) : BasePresenter(),
    VipHomeContract.Presenter {

    val meModel: MeModel by lazy { MeModel() }
    val userModel: UserModel by lazy { UserModel() }
    override fun loadVipList() {
        mView.showLoadingDialog()
        meModel.getVipList().subscribe(object :CommonSubscriber<List<VipBean>>(compositeDisposable){
            override fun onCallNext(t: List<VipBean>?) {
                mView.loadVipListSucess(t!!)
            }

            override fun onCallCompleted() {
                super.onCallCompleted()
                mView.hideLoadingDialog()
            }

            override fun onCallError(e: String) {
                super.onCallError(e)
                showToast(e)
            }

        })
    }

    override fun loadUserInfo() {
        mView.showLoadingDialog()
        userModel.getUserInfo()
            .subscribe(object : CommonSubscriber<UserInfoBean>(compositeDisposable) {

                override fun onCallNext(t: UserInfoBean?) {
                    mView.loadUserInfoSuccess(t!!)
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }
            })
    }


}

